/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2024-01-17
 * Time: 12:51
 */
import java.util.Scanner;

public class AdminMember {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        TestOfMember testOfMember = new TestOfMember();
        while (true) {
            System.out.println("**********   会员窗口   *********");
            System.out.println("\t\t1、显示所有会员");
            System.out.println("\t\t2、添加会员信息");
            System.out.println("\t\t3、修改会员信息");
            System.out.println("\t\t4、查询会员信息");
            System.out.println("\t\t5、删除会员信息");
            System.out.println("\t\t6、返回上一层");
            System.out.println("*******************************");
            System.out.println("请输入对应编号：");
            int n = in.nextInt();
            while (n < 1 || n > 6) {
                System.out.println("输入错误！请重新输入：");
                n = in.nextInt();
            }
            switch (n) {
                case 1://显示所有会员
                    testOfMember.displayOfMenber();
                    break;
                case 2://添加会员信息
                    System.out.println("**********   会员注册   *********");
                    testOfMember.addMember();
                    System.out.println("*********   会员注册结束   ********");
                    break;
                case 3://修改会员信息
                    System.out.println("**********   会员修改   *********");
                    while (true) {
                        System.out.println("请输入您要修改的会员ID：");
                        if (testOfMember.queryMember(in.next())) {
                            System.out.println("*******************************");
                            System.out.println("\t\t1、修改生日");
                            System.out.println("\t\t2、修改积分");
                            System.out.println("\t\t3、修改生日和积分");
                            System.out.println("*******************************");
                            String oldstr = testOfMember.toString();
                            switch (in.nextInt()) {
                                case 1:
                                    System.out.println("请输入生日：");
                                    testOfMember.getMember().setMemberBirth(in.next());
                                    break;
                                case 2:
                                    System.out.println("请输入积分：");
                                    testOfMember.getMember().setMemberIntegral(in.nextInt());
                                    break;
                                case 3:
                                    System.out.println("请输入生日：");
                                    testOfMember.getMember().setMemberBirth(in.next());
                                    System.out.println("请输入积分：");
                                    testOfMember.getMember().setMemberIntegral(in.nextInt());
                                    break;
                                default:
                                    System.out.println("输入的数字错误！");
                            }
                            String newstr = testOfMember.toString();
                            testOfMember.modify(oldstr, newstr);
                        } else {
                            System.out.println("没要找到该会员！");
                        }
                        System.out.println("是否继续修改？(Y/N)");
                        char c = in.next().charAt(0);
                        if (c == 'n' || c == 'N')
                            break;
                    }
                    System.out.println("*********   会员修改结束   ********");
                    break;
                case 4://查询会员信息
                    System.out.println("**********   会员窗口   **********");
                    while (true) {
                        System.out.println("请输入您要查找的会员ID：");
                        if (!testOfMember.queryMember(in.next())) {
                            System.out.println("没要找到该会员！");
                        }
                        System.out.println("是否继续查找？(Y/N)");
                        char c = in.next().charAt(0);
                        if (c == 'n' || c == 'N')
                            break;
                    }
                    System.out.println("*********   会员查询结束   *********");
                    break;
                case 5://删除会员信息
                    testOfMember.deleteMember();
                    break;
                case 6:
                    return;
            }
            System.out.println("是否返回上一个界面：Y-是，N-否");
            char ch = in.next().charAt(0);
            if (ch == 'n' || ch == 'N')
                break;
        }
    }
}